#include "listspec.h"
#include "ui_listspec.h"

ListSpec::ListSpec(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ListSpec)
{
    ui->setupUi(this);

    tblSpec = new QSqlTableModel(this);
    tblSpec->setTable("\"CSPECIALITY\"");
    tblSpec->select();

    ui->tableSpec->setModel(tblSpec);
    ui->tableSpec->setWordWrap(true);

    setNameFields();
}

ListSpec::~ListSpec()
{
    delete ui;
}

void ListSpec::setNameFields()
{

    //tblSpec->setHeaderData(room_num, Qt::Horizontal, tr("Num room"));
    //tblSpec->setHeaderData(roomtype_name, Qt::Horizontal, tr("Type room"));
    //tblSpec->setHeaderData(room_about, Qt::Horizontal, tr("Description"));
    //tblRoom->setHeaderData(ViewKab_fam_io, Qt::Horizontal, tr("Managing an office"));

    ui->tableSpec->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->tableSpec->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->tableSpec->setEditTriggers(QAbstractItemView::NoEditTriggers);

    //ui->tableSpec->setColumnHidden(men_respond_id, true);
    //ui->tableSpec->setColumnHidden(roomtype_id, true);

    ui->tableSpec->resizeColumnsToContents();

    QHeaderView *header = ui->tableSpec->horizontalHeader();
    header->setStretchLastSection(true);
}
